*------------- Upper-Body Strength and Political Egalitarianism: Twelve Conceptual Replications ------------------------------------*
*----------------------------------------------------- STUDY 11 --------------------------------------------------------------------*

*-------------------------------------------------- Background variables -----------------------------------------------------------*
** Gender
destring bkgrnd_gender, replace ignore("NA")
gen gender = bkgrnd_gender
label define genderLB 1 "female" 2 "male"
label values gender genderLB

** Age
destring bkgrnd_age, replace ignore("NA")
gen age = bkgrnd_age

** Education 
destring bkgrnd_udd1, replace ignore("NA")
gen education = bkgrnd_udd1

label define eduLB 1 "Grund-/Folkeskole" 2 "STX/HF" 3 "HH/HHX/HTX" 4 "Erhvervsfaglig udd." 5 "kort videregående udd." 6 "Mellemlang videregående udd." 7 "Lang videregående udd." 8 "PhD/forsker" 9 "ønsker ikke at svare"
label values education eduLB

recode education (1=1) (4=2) (2 3 =3) (5=4) (6=5) (7=6) (8=7) (9=.), generate(uddannelse)

** Income
destring bkgrnd_personal_income, replace ignore ("NA")
recode bkgrnd_personal_income (12=.) (13=.)
gen income = bkgrnd_personal_income


***** Physiological measures
destring strength_handgrip1 strength_handgrip2 strength_chest1 strength_chest2, replace ignore ("NA")

summ strength_handgrip1 strength_handgrip2 strength_chest1 strength_chest2

factor strength_handgrip1 strength_handgrip2 strength_chest1 strength_chest2, pcf
//Result: One dimension


* Dynamomter - creates variable for largest value across the two trials
egen hand_strength = rowmax(strength_handgrip1 strength_handgrip2)

* Reverse dynamometer - creates variable for largest value across the two trials
egen chest_strength = rowmax(strength_chest1 strength_chest2)

bys gender: summ hand_strength
bys gender: summ chest_strength



**** Identifies outlier observation with extreme strengt value reported
*Finds ID-number for extreme observation
tab chest_strength id if gender == 1 & chest_strength > 200

*Drops outlier
drop if id == 15


** Creates composite Physical Strength variable based on Principal Component Analysis
factor hand_strength chest_strength, pcf
predict physstrength

bys gender: summ physstrength
hist physstrength if gender == 1


** Recodes formidability variable to 0-1 scale reflecting min. and max. values within sex
summ physstrength if gender == 1
generate physmorph_factor = (physstrength-(r(min)))/(r(max)-r(min)) if gender == 1

summ physstrength if gender == 2
replace physmorph_factor = (physstrength-(r(min)))/(r(max)-r(min)) if gender == 2

bys gender: summ physmorph_factor


*---------------------------------- Ideology measures, Dependent Variables ------------------------------------------*

** Economic conservatism on 0-1 scale reflecting observed min. max. values within sex
destring presvy_q47_1 presvy_q47_2 presvy_q47_3 presvy_q47_4 presvy_q47_5, replace ignore("NA")
recode presvy_q47_1 (6=.) (5=1) (4=2) (2=4) (1=5)
recode presvy_q47_2 (6=.) (5=1) (4=2) (2=4) (1=5)
recode presvy_q47_3 (6=.) (5=1) (4=2) (2=4) (1=5)
recode presvy_q47_4 (6=.) 
recode presvy_q47_5 (6=.) 

alpha presvy_q47_1 presvy_q47_2 presvy_q47_3 presvy_q47_4 presvy_q47_5

egen econCons = rowmean(presvy_q47_1 presvy_q47_2 presvy_q47_3 presvy_q47_4 presvy_q47_5)

summ econCons if gender == 1 & physmorph_factor !=.
generate economic_conservatism = (econCons-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ econCons if gender == 2 & physmorph_factor !=.
replace economic_conservatism = (econCons-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.


** Social Dominance Orientation scale
destring bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8, replace ignore("NA")
alpha bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8
recode bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_7 bkgrnd_q9_8 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
egen sdo = rowmean(bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8)

*Recodes to 0-1 scale reflecting min. max. values for females and males, respectively
summ sdo if gender == 1 & physmorph_factor !=.
generate SDO = (sdo-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ sdo if gender == 2 & physmorph_factor !=.
replace SDO = (sdo-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.


** SDO dimensions - measured on 0-1 scales reflecting min. and max. values for females and males, respectively
* SDO-D
egen sdo_d = rowmean(bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4)
summ sdo_d if gender == 1 & physmorph_factor !=.
generate SDO_D = (sdo_d-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ sdo_d if gender == 2 & physmorph_factor !=.
replace SDO_D = (sdo_d-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.

bys gender: summ SDO_D

* SDO-E
egen sdo_e = rowmean(bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8)
summ sdo_e if gender == 1 & physmorph_factor !=.
generate SDO_E = (sdo_e-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ sdo_e if gender == 2 & physmorph_factor !=.
replace SDO_E = (sdo_e-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.

bys gender: summ SDO_E


*** Rightwing Authoritarianism - measured on 0-1 scales reflecting min. and max. values for females and males, respectively
destring bkgrnd_q10_1 bkgrnd_q10_2 bkgrnd_q10_3 bkgrnd_q10_4 bkgrnd_q10_5 bkgrnd_q10_6 bkgrnd_q10_7 bkgrnd_q10_8, replace ignore("NA")
alpha bkgrnd_q10_1 bkgrnd_q10_2 bkgrnd_q10_3 bkgrnd_q10_4 bkgrnd_q10_5 bkgrnd_q10_6 bkgrnd_q10_7 bkgrnd_q10_8
recode bkgrnd_q10_2 bkgrnd_q10_6 bkgrnd_q10_7 bkgrnd_q10_8 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
egen rwa = rowmean(bkgrnd_q10_1 bkgrnd_q10_2 bkgrnd_q10_3 bkgrnd_q10_4 bkgrnd_q10_5 bkgrnd_q10_6 bkgrnd_q10_7 bkgrnd_q10_8)
*Recodes to 0-1 scale for observed min and max within sex
summ rwa if gender == 1 & physmorph_factor !=.
generate RWA = (rwa-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ rwa if gender == 2 & physmorph_factor !=.
replace RWA = (rwa-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.
bys gender: summ RWA

***Left-right self-placement
destring bkgrnd_q8a, replace ignore("NA")
generate leftright = bkgrnd_q8a/10


*-------------------------------------------------- CONTROL VAERIABLES -----------------------------------------------------*
*** Personality measures: Big Five
destring presvy_q2_1 presvy_q2_2 presvy_q2_3 presvy_q2_4 presvy_q2_5 presvy_q2_6 presvy_q2_7 presvy_q2_8 presvy_q2_9 presvy_q2_10, replace ignore ("NA")
recode presvy_q2_2 presvy_q2_6 presvy_q2_8 presvy_q2_9 presvy_q2_10 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)

* Creates variables for all five traits seperately
egen openness = rowmean(presvy_q2_5 presvy_q2_10)

egen conscientious = rowmean(presvy_q2_3 presvy_q2_8)

egen agreeable = rowmean(presvy_q2_2 presvy_q2_7)

egen extraversion = rowmean(presvy_q2_1 presvy_q2_6)

egen neuroticism = rowmean(presvy_q2_4 presvy_q2_9)

** Recodes traits to 0-1 scale for observed min and max for feamles and males, respectively
* Openness
summ openness if gender == 1 & physmorph_factor !=.
generate open01 = (openness-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ openness if gender == 2 & physmorph_factor !=.
replace open01 = (openness-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.

* Conscientiousness
summ conscientious if gender == 1 & physmorph_factor !=.
generate consc01 = (conscientious-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ conscientious if gender == 2 & physmorph_factor !=.
replace consc01 = (conscientious-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.

* Agreeableness
summ agreeable if gender == 1 & physmorph_factor !=.
generate agree01 = (agreeable-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ agreeable if gender == 2 & physmorph_factor !=.
replace agree01 = (agreeable-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.

* Extraversion
summ extraversion if gender == 1 & physmorph_factor !=.
generate extra01 = (extraversion-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ extraversion if gender == 2 & physmorph_factor !=.
replace extra01 = (extraversion-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.

* Neuroticism
summ neuroticism if gender == 1 & physmorph_factor !=.
generate neuro01 = (neuroticism-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ neuroticism if gender == 2 & physmorph_factor !=.
replace neuro01 = (neuroticism-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.


*** Network content variables
destring presvy_q17 presvy_q20 presvy_q21 presvy_q22 presvy_q22_text, replace ignore("NA")

* Unemployment
generate unemployment_experience = presvy_q21
label define unemplLB 1 "currently - self or near family" 2 "has been - self or near family" 3 "no - neither self nor near family" 4 "don't want to answer"
label values unemployment_experience unemplLB

* Immigrant friends
generate immigrant_friends = presvy_q17
label define immigrant_friendsLB 1 "none" 2 "one" 3 "a few" 4 "some" 5 "Many" 6 "don't want to answer"
label values immigrant_friends immigrant_friendsLB


*** Socio-Economic Status variable based on income, home ownership and education
destring bkgrnd_udd1 bkgrnd_household_income bkgrnd_personal_income bkgrnd_profile_house_tenure, replace ignore("NA")

** Education
tab1 bkgrnd_udd1
recode bkgrnd_udd1 (1=1) (2 3 = 2) (4=3) (5=4) (6=5) (7=6), generate(educat)
* Creates standardized variable
egen std_education = std(educat)

** Income
* Averaging across household and personal income
tab1 bkgrnd_household_income bkgrnd_personal_income
recode bkgrnd_household_income bkgrnd_personal_income (12 13=.)
egen income_average = rowmean(bkgrnd_household_income bkgrnd_personal_income)
* Creates standardized variable
egen std_income = std(income_average)

** Home ownership
tab bkgrnd_profile_house_tenure
recode bkgrnd_profile_house_tenure (97 98=.), generate(homeownership)
* Creates standardized variable
egen std_homeownership = std(homeownership)


**** Creates composite SES scale
summ std_education std_income std_homeownership
egen SES_scale = rowmean(std_education std_income std_homeownership)

* Recodes to 0-1 scale reflecting min and max observed values within gender
summ SES_scale if gender == 1 & physmorph_factor !=.
generate SES_scale01 = (SES_scale-(r(min)))/(r(max)-r(min)) if gender == 1 & physmorph_factor !=.

summ SES_scale if gender == 2 & physmorph_factor !=.
replace SES_scale01 = (SES_scale-(r(min)))/(r(max)-r(min)) if gender == 2 & physmorph_factor !=.


*-------------------------------------------------------- DESCRIPTIVES --------------------------------------------------------*
summ age if physmorph_factor !=.
tab gender if physmorph_factor !=.

*Formidability
bys gender: summ physmorph_factor

*SDO
alpha bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8 if physmorph_factor !=.
bys gender: summ SDO if physmorph_factor !=.

*Economic Cons.
alpha presvy_q47_1 presvy_q47_2 presvy_q47_3 presvy_q47_4 presvy_q47_5 if physmorph_factor !=. & gender !=.
bys gender: summ economic_conservatism if physmorph_factor !=. & gender !=.

*RWA
alpha bkgrnd_q10_1 bkgrnd_q10_2 bkgrnd_q10_3 bkgrnd_q10_4 bkgrnd_q10_5 bkgrnd_q10_6 bkgrnd_q10_7 bkgrnd_q10_8 if physmorph_factor !=.
bys gender: summ RWA if physmorph_factor !=.

*Big Five
bys gender: summ open01 consc01 extra01 agree01 neuro01

*SES scale
bys gender: summ SES_scale01



*-------------------------------------------------------- Analyses ------------------------------------------------------------*
**** Does Physical Strength predict SDO?
* Females
reg SDO physmorph_factor c.age c.uddannelse if gender == 1

* Males
reg SDO physmorph_factor c.age c.uddannelse if gender == 2


**** Does Physical Strength predict SDO's sub-dimensions?
** SDO-D
* Females
reg SDO_D physmorph_factor c.age c.uddannelse if gender == 1

* Males
reg SDO_D physmorph_factor c.age c.uddannelse if gender == 2

** SDO-E
* Females
reg SDO_E physmorph_factor c.age c.uddannelse if gender == 1

* Males
reg SDO_E physmorph_factor c.age c.uddannelse if gender == 2


**** Does Physical Strength predict RWA?
* Females
reg RWA physmorph_factor c.age c.uddannelse if gender == 1

* Males
reg RWA physmorph_factor c.age c.uddannelse if gender == 2


**** Does Physical Strength predict Economic Conservatism?
* Females
reg economic_conservatism physmorph_factor c.age c.uddannelse if gender == 1

* Males
reg economic_conservatism physmorph_factor c.age c.uddannelse if gender == 2



**** Does Physiccal Strength predict Economic Conservatism THROUGH Social Dominance Orientation? (Mediation analyses)
* Only Males
sem (age education physmorph_factor -> SDO if gender==2) ///
	(age education physmorph_factor SDO -> economic_conservatism), nocapslatent
	
estat teffects
estat gof, stats(all)

* Only FEMALES
sem (age education physmorph_factor -> SDO if gender==1) ///
	(age education physmorph_factor SDO -> economic_conservatism), nocapslatent
	
estat teffects
estat gof, stats(all)



**** Robustness analyses controlling for Big Five personality traits
** Prediction of SDO by Physical Strength
* Female subjects
reg SDO physmorph_factor c.age c.uddannelse open01 consc01 extra01 agree01 neuro01 if gender == 1

* Male subjects
reg SDO physmorph_factor c.age c.uddannelse open01 consc01 extra01 agree01 neuro01 if gender == 2

** Prediction of Economic Conservatism by Physical Strength
* Female subjects
reg economic_conservatism physmorph_factor c.age c.uddannelse open01 consc01 extra01 agree01 neuro01 if gender == 1

* Male subjects
reg economic_conservatism physmorph_factor c.age c.uddannelse open01 consc01 extra01 agree01 neuro01 if gender == 2


**** Robustness analyses controlling for content of social network
** Prediction of SDO by Physical Strength
* Female subjects
reg SDO physmorph_factor c.age c.uddannelse ib(3).unemployment_experience ib(1).immigrant_friends if gender == 1

* Male subjects
reg SDO physmorph_factor c.age c.uddannelse ib(3).unemployment_experience ib(1).immigrant_friends if gender == 2

** Prediction of Economic Conservatism by Physical Strength
* Female subjects
reg economic_conservatism physmorph_factor c.age c.uddannelse ib(3).unemployment_experience ib(1).immigrant_friends if gender == 1

* Male subjects
reg economic_conservatism physmorph_factor c.age c.uddannelse ib(3).unemployment_experience ib(1).immigrant_friends if gender == 2


**** Robustness analyses: Does respondents' SES moderate the relationship between Physical Strength and the dependent variables (SDO & Economic Conservatism)
** Prediction of SDO by Physical Strength
* Female subjects
reg SDO c.physmorph_factor##c.SES_scale01 c.age c.uddannelse if gender == 1

margins, dydx(physmorph_factor) at(SES_scale01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Male subjects
reg SDO c.physmorph_factor##c.SES_scale01 c.age c.uddannelse if gender == 2

margins, dydx(physmorph_factor) at(SES_scale01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)


** Prediction of Economic Conservatism by Physical Strength
* Female subjects
reg economic_conservatism c.physmorph_factor##c.SES_scale01 c.age c.uddannelse if gender == 1

margins, dydx(physmorph_factor) at(SES_scale01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Male subjects
reg economic_conservatism c.physmorph_factor##c.SES_scale01 c.age c.uddannelse if gender == 2

margins, dydx(physmorph_factor) at(SES_scale01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)



**** Robustness analyses: Does formidability relate stronger to anti-egalitarianism among younger than older males?
** Males
* Prediction of SDO by Physical Strength X age
reg SDO c.physmorph_factor##c.age c.uddannelse if gender == 2

margins, dydx(physmorph_factor) at(age=(18 (1) 70))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Prediction of Economic Conservatism by Physical Strength X age
reg economic_conservatism c.physmorph_factor##c.age c.uddannelse if gender == 2

margins, dydx(physmorph_factor) at(age=(18 (1) 70))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)


** Females
* Prediction of SDO by Physical Strength X age
reg SDO c.physmorph_factor##c.age c.uddannelse if gender == 1

margins, dydx(physmorph_factor) at(age=(18 (1) 70))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Prediction of Economic Conservatism by Physical Strength X age
reg economic_conservatism c.physmorph_factor##c.age c.uddannelse if gender == 1

margins, dydx(physmorph_factor) at(age=(18 (1) 70))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)


***** Does the insignificant interactions between age and Physical Strength replicate using a dichotomous age variable (below median age vs. above median age)
* Creates dichotomous age variable
* Males
summ age if gender == 2, detail
generate age_medsplit =.
replace age_medsplit = 1 if age > 41 & gender == 2
replace age_medsplit = 0 if age <= 41 & gender == 2
* Females
summ age if gender == 1, detail
replace age_medsplit = 1 if age > 43 & gender == 1
replace age_medsplit = 0 if age <= 43 & gender == 1


*** Formidability X age interactions using dichotomous age variable:
** Males
* Prediction of SDO by Physical Strength X age
reg SDO c.physmorph_factor##i.age_medsplit c.uddannelse if gender == 2

margins, dydx(physmorph_factor) at(age_medsplit=(0 (1) 1))
marginsplot, recastci(rcap) ciopts(lpattern(dash)) recast(bar) yline(0) xlabel(#2) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Prediction of Economic Conservatism by Physical Strength X age
reg economic_conservatism c.physmorph_factor##i.age_medsplit c.uddannelse if gender == 2

margins, dydx(physmorph_factor) at(age_medsplit=(0 (1) 1))
marginsplot, recastci(rcap) ciopts(lpattern(dash)) recast(bar) yline(0) xlabel(#2) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)


** Females
* Prediction of SDO by Physical Strength X age
reg SDO c.physmorph_factor##i.age_medsplit c.uddannelse if gender == 1

margins, dydx(physmorph_factor) at(age_medsplit=(0 (1) 1))
marginsplot, recastci(rcap) ciopts(lpattern(dash)) recast(bar) yline(0) xlabel(#2) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Prediction of Economic Conservatism by Physical Strength X age
reg economic_conservatism c.physmorph_factor##i.age_medsplit c.uddannelse if gender == 1

margins, dydx(physmorph_factor) at(age_medsplit=(0 (1) 1))
marginsplot, recastci(rcap) ciopts(lpattern(dash)) recast(bar) yline(0) xlabel(#2) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)
